package com.lcy.struct.bTreePlus.disk.file;

import com.lcy.struct.bTreePlus.property.BPlusFileInfo;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.List;

/**
 * @author lucongyang
 * @date Created in  10:19
 * @description
 */
public abstract class AbstractFileWriter {
    public void modify(String filePath) {
        try {
            RandomAccessFile randomAccessFile = new RandomAccessFile(filePath, "rw");
            FileChannel channel = randomAccessFile.getChannel();
            multiplyUseChannel(channel);
            randomAccessFile.close();
        } catch (Exception e) {
            throw new RuntimeException("写文件出错");
        }
    }

    /**
     * 通道复用
     */
    public abstract void multiplyUseChannel(FileChannel channel);
}
